using System;
using System.Collections.Generic;
using System.Text;

using phorm.database.core;

namespace phorm.model.fields
{
    /// <summary>
    /// A UNIX Timestamp that is inserted only at creation time.
    /// </summary>
    public class CreationTimestamp : UnixTimestamp, IInsertOnlyColumn
    {
        /// <summary>
        /// Constructor extends base constructor and relies on it for any work to be completed.
        /// </summary>
        /// <param name="obj">The database record to which this column belongs.</param>
        public CreationTimestamp(DatabaseRecord obj)
            : base (obj)
        {
        }

        /// <summary>
        /// Definition of insert method required by IInsertOnlyColumn. Sets value to current timestamp using UnixTimestamp.now() method.
        /// </summary>
        public void insert()
        {
            this.value = now();
        }
    }
}
